<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  es6 里面的 ?. 
  <p>obj?.name == obj && obj.name</p>
  <script>
    const obj = {
      name: 'tom',
      age: 0
    }
    const obj2 = null
    if(obj?.age) {
      console.log('has age')
    }else{
      console.log('has no age')
    }
    if(obj?.name) {
      console.log('has name')
    }else{
      console.log('has no name')
    }
    if(obj?.hhh) {
      console.log('has hhh')
    }else{
      console.log('has no hhh')
    }

    if(obj2?.hhh) {
      console.log('obj2 has hhh')
    }else{
      console.log('obj2 has no hhh')
    }
  </script>
</body>
</html>